package org.ThreadDemo.sync;

import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class Demo01 {

    public static void main(String[] args) {

        ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
        ReentrantReadWriteLock.ReadLock readLock = rwLock.readLock();
        ReentrantReadWriteLock.WriteLock writeLock = rwLock.writeLock() ;



        writeLock.lock();
        System.out.println("get the write lock");
        //writeLock.unlock();

        readLock.lock();
        System.out.println("get the read lock");
        //writeLock.unlock();

        writeLock.unlock();

        readLock.unlock();


    }
}
